package com.errol.batchprocessor.employeeaddition.advisorimpl.enhance;

import com.renjia.entity.CoreEmployeeImportBatch;
import com.renjia.service.generic.log.LogService;
import com.renjia.service.generic.middleware.batchprocessor.advisorimpl.timeconsole.AbstractTimeConsoleAdvisorImpl;
import com.renjia.service.generic.middleware.batchprocessor.payload.AbstractBatchPayload;
import com.renjia.service.module.employeeaddition.advisor.*;
import com.renjia.service.module.employeeaddition.advisorimpl.EmployeeAdvisorTypeEnum;
import com.renjia.service.module.employeeaddition.advisorimpl.common.payload.AbstractEmployeeBatchPayload;
import com.renjia.service.module.employeeaddition.advisorimpl.common.payload.AbstractEmployeePiecePayload;
import com.renjia.service.module.employeeaddition.advisorimpl.common.payload.AbstractEmployeeSinglePayload;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Service;

/**
 * 人员导入时间统计扩展
 *
 * @author zhang xiao bin
 * @version v1.0
 * @date 2021/03/12
 * @since v5.0.6
 **/
@Service
public class EmployeeAdditionTimeAdvisorImpl<BE, SE, BP extends AbstractEmployeeBatchPayload<BE, SE>, PP extends AbstractEmployeePiecePayload<SE, SP>, SP extends AbstractEmployeeSinglePayload<SE>>
        extends AbstractTimeConsoleAdvisorImpl<CoreEmployeeImportBatch, EmployeeAdvisorTypeEnum, BE, SE, BP, PP, SP>
        implements
        EmployeeBatchAddAdvisor<BE, SE, BP, PP, SP>, EmployeeBatchStartAdvisor<BE, SE, BP, PP, SP>, EmployeeBatchPostAdvisor<BE, SE, BP, PP, SP>,
        EmployeePieceStartAdvisor<BE, SE, BP, PP, SP>, EmployeePiecePostAdvisor<BE, SE, BP, PP, SP> {

    public EmployeeAdditionTimeAdvisorImpl(LogService logService) {
        super(logService);
    }

    @Override
    public boolean shallProcess(@NonNull AbstractBatchPayload<CoreEmployeeImportBatch, EmployeeAdvisorTypeEnum, BE, SE> advisorPayload) {
        // 导入时间统计，导入时执行
        return advisorPayload.getAdvisorTypeEnum().getCode() > 0;
    }

    @Override
    protected String logPrefix() {
        return "【人员导入批处理】";
    }
}
